<!DOCTYPE html>
<html>
<head>
<include file="Include:meta" />
<title>商务跟进项目-目的地运营集团数据管理平台</title>
<include file="Include:style" />
</head>
<body>
<include file="Include:header" />
<include file="Include:left" />
<div id="main">
	<div class="crumbs">
		<div class="crumbs-text">商务跟进项目</div>
		<div class="right">
			<div class="input-group left w200">
		    	<input type="text" id="keyword" value="{$keyword}" class="form-control" placeholder="按项目编号/名称搜索" autocomplete="off">
	    		<span class="input-group-btn">
	        		<button class="btn found_btn" type="button">搜索</button>
		    	</span>
		    </div>
			<if condition="get_permission('SW',1,1)">
				<a href="__APP__/Index/label_administration/classif/6/types/项目" class="btn left ml5" target="_blank">标签管理</a>
			</if>
			<if condition="get_permission('SW',NULL,1) or (get_permission('SW',NULL,2) and (in_array($center_id,$login_sw_manage_id))) or get_permission('SW',NULL,3)">
				<a href="__APP__/Project/project_add/center_id/{$center_id}/sw/1" class="btn left ml5">添加商务跟进项目</a>
			</if>
		</div>
	</div>
	<div id="content">
		<div class="filter">
			<div class="filter-item">
				<div class="filter-title">项目状态：</div>
				<ul class="filter-order">
					<foreach name="status_list" item="vo">
					<li <if condition="$status_id eq $vo['name2']">class="current"</if>>
						<a href="__APP__/Project/business_follow/keyword/{$keyword}/center_id/{$center_id}/status_id/{$vo['name2']}/stage/{$stage}" <if condition="$vo['name2'] neq 1 and $vo['name2'] neq -10">title="({$vo['name3']})"</if>>{$vo['name1']}<if condition="$vo['sum'] neq 0 and $center_id neq 130003">({$vo['sum']})</if></a>
					</li>
					</foreach>
				</ul>
			</div>
			<div class="filter-item">
				<div class="filter-title">项目比率：</div>
				<ul class="filter-order">
					<li <if condition="$stage eq -10">class="current"</if>>
						<a href="__APP__/Project/business_follow/keyword/{$keyword}/center_id/{$center_id}/status_id/{$status_id}/stage/-10">全部</a>
					</li>
					<li <if condition="$stage eq 1">class="current"</if>>
						<a href="__APP__/Project/business_follow/keyword/{$keyword}/center_id/{$center_id}/status_id/{$status_id}/stage/1">前期推进(<60%) </a>
					</li>
					<li <if condition="$stage eq 2">class="current"</if>>
						<a href="__APP__/Project/business_follow/keyword/{$keyword}/center_id/{$center_id}/status_id/{$status_id}/stage/2">签订框架协议(60%)</a>
					</li>
					<li <if condition="$stage eq 4">class="current"</if>>
						<a href="__APP__/Project/business_follow/keyword/{$keyword}/center_id/{$center_id}/status_id/{$status_id}/stage/4">已签约(90%)</a>
					</li>
					<li <if condition="$stage eq 5">class="current"</if>>
						<a href="__APP__/Project/business_follow/keyword/{$keyword}/center_id/{$center_id}/status_id/{$status_id}/stage/5">首款已到(100%)</a>
					</li>
				</ul>
			</div>
		</div>
		<div class="table-scrollx">
			<table class="table table-bordered table-hover">
				<tr class="table-header fixed-table-header">
					<td width="168">
						<select name="project_num" class="form-control w150">
							<option value="-10"<if condition="$project_num eq -10"> selected</if>>项目编号</option>
							<foreach name="result1" item="vo">
							<option value="{$vo['project_num']}"<if condition="$project_num eq $vo['project_num']"> selected</if>>{$vo['project_num']}</option>
							</foreach>
						</select>
					</td>
					<td width="418">
						<select name="project_name" class="form-control w400">
							<option value="-10"<if condition="$project_name eq -10"> selected</if>>项目名称</option>
							<foreach name="result1" item="vo">
							<option value="{$vo['project_name']}"<if condition="$project_name eq $vo['project_name']"> selected</if>>{$vo['project_name']}</option>
							</foreach>
						</select>
					</td>
					<td width="102">
						<select name="manager_uid" class="form-control" style="width:100px;">
							<option value="-10"<if condition="$manager_uid eq -10"> selected</if>><if condition="$center_id eq 130005">项目负责人<else/>项目经理</if></option>
							<foreach name="result2" item="vo">
							<option value="{$vo['manager_uid']}"<if condition="$manager_uid eq $vo['manager_uid']"> selected</if>>{$vo['manager_name']}</option>
							</foreach>
						</select>
					</td>
					<td width="102">
						<select name="director_uid" class="form-control" style="width:105px;">
							<option value="-10"<if condition="$director_uid eq -10"> selected</if>><if condition="$center_id eq 130005">项目群负责人<else/>项目总监</if></option>
							<foreach name="result3" item="vo">
							<option value="{$vo['director_uid']}"<if condition="$director_uid eq $vo['director_uid']"> selected</if>>{$vo['director_name']}</option>
							</foreach>
						</select>
					</td>
					<td width="86">启动日期</td>
					<td width="90">
						<select name="bus_status" class="form-control w90">
							<option value="-10"<if condition="$bus_status eq -10"> selected</if>>阶段比率</option>
							<option value="0"<if condition="$bus_status eq 0"> selected</if>>0%</option>
							<option value="10"<if condition="$bus_status eq 10"> selected</if>>10%</option>
							<option value="20"<if condition="$bus_status eq 20"> selected</if>>20%</option>
							<option value="40"<if condition="$bus_status eq 40"> selected</if>>40%</option>
							<option value="50"<if condition="$bus_status eq 50"> selected</if>>50%</option>
							<option value="60"<if condition="$bus_status eq 60"> selected</if>>60%</option>
							<option value="90"<if condition="$bus_status eq 90"> selected</if>>90%</option>
							<option value="100"<if condition="$bus_status eq 100"> selected</if>>100%</option>
						</select>
					</td>
					<if condition="get_permission('SW',NULL,1) or (get_permission('SW',NULL,2) and (in_array($center_id,$login_sw_manage_id))) or get_permission('SW',NULL,3)">
						<td width="50">管理</td>
					</if>
				</tr>
				<if condition="$result eq NULL">
				<tr>
					<td <if condition="get_permission('SW',NULL,1) or (get_permission('SW',NULL,2) and (in_array($center_id,$login_sw_manage_id))) or get_permission('SW',NULL,3)">colspan="7"<else />colspan="6"</if> class="text-center">暂无相关内容</td>
				</tr>
				</if>
				<foreach name="result" item="vo">
				<tr>
					<td><a href="__APP__/Project/project_situation/id/{$vo['id']}" target="_blank">{$vo['project_num']}</a></td>
					<td>{$vo['project_name']}</td>
					<td>{$vo['manager_name']}</td>
					<td>{$vo['director_name']}</td>
					<td>{$vo['start_date']}</td>
					<td>
					<if condition="$vo['lb'] eq 10">
						<span data-toggle="tooltip" data-placement="right" title="项目信息完成">{$vo['lb']}%</span>
					<elseif condition="$vo['lb'] eq 20"/>
						<span data-toggle="tooltip" data-placement="right" title="交流接洽中">{$vo['lb']}%</span>
					<elseif condition="$vo['lb'] eq 40"/>
						<span data-toggle="tooltip" data-placement="right" title="考察/接待实施">{$vo['lb']}%</span>
					<elseif condition="$vo['lb'] eq 50"/>
						<span data-toggle="tooltip" data-placement="right" title="建议书已接交">{$vo['lb']}%</span>
					<elseif condition="$vo['lb'] eq 60"/>
						<span data-toggle="tooltip" data-placement="right" title="已提交正式协议">{$vo['lb']}%</span>
					<elseif condition="$vo['lb'] eq 90"/>
						<span data-toggle="tooltip" data-placement="right" title="已签约">{$vo['lb']}%</span>
					<elseif condition="$vo['lb'] eq 100"/>
						<span data-toggle="tooltip" data-placement="right" title="首款已到">{$vo['lb']}%</span>
					<else />
						{$vo['lb']}%
					</if>
					</td>
					<if condition="get_permission('SW',NULL,1) or (get_permission('SW',NULL,2) and (in_array($center_id,$login_sw_manage_id))) or get_permission('SW',NULL,3)">
					<td class="nowrap">
						<if condition="((get_permission('SW',NULL,3)) and ($vo['add_uid'] eq $login_id or $vo['manager_uid'] eq $login_id or $vo['director_uid'] eq $login_id)) or (get_permission('SW',NULL,2) and (in_array($vo['center_id'],$login_sw_manage_id))) or (get_permission('SW',NULL,1))">
							<if condition="$vo['status'] eq 1">
								<a href="__APP__/Project/project_edit/keyword/{$keyword}/center_id/{$center_id}/status_id/{$status_id}/project_num/{$project_num}/project_name/{$project_name}/manager_uid/{$manager_uid}/director_uid/{$director_uid}/id/{$vo['id']}/bus_status/{$bus_status}/stage/{$stage}/sw/1" data-toggle="tooltip" data-placement="left" title="编辑" class="mr5"><i class="glyphicon glyphicon-edit"></i></a>
								<a href="javascript:;" class="operate" cid="{$vo['center_id']}" num="{$vo['lb']}" data-toggle="tooltip" data-placement="left" title="操作" mid="{$vo['id']}"><i class="glyphicon glyphicon-wrench"></i></a>
							<else />
								<a href="javascript:;" class="start-using" data-toggle="tooltip" data-placement="left" title="启用" mid="{$vo['id']}" status="1"><i class="glyphicon glyphicon-ok"></i></a>
							</if>
						</if>
					</td>
					</if>
				</tr>
				</foreach>
			</table>
		</div>
		<div class="pages">{$page}</div>
	</div>
</div>
<!--对话框-->
<div class="modal fade" id="myModal-operate">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<h4>操作提示框</h4>
				<i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
			</div>
			<div class="modal-body">
				<table class="table table-bordered">
					<tr>
						<td class="text-right" width="50"><strong><span class="asterisk">*</span>日期</strong></td>
						<td>
							<input type="text" class="form-control Wdate stop_date w100" onclick="WdatePicker()" readonly autocomplete="off">
							<span class="error-item">必填项</span>
						</td>
					</tr>
					<tr>
						<td class="text-right"><strong><span class="asterisk">*</span>状态</strong></td>
						<td>
							<label class="radio-inline" title="协商解决中">
								<input type="radio" class="type" name="type[]" value="-2" autocomplete="off">暂停
							</label>
							<label class="radio-inline" title="合同到期">
								<input type="radio" class="type" name="type[]" value="-3" autocomplete="off">完结
							</label>
							<label class="radio-inline" title="合同中止">
								<input type="radio" class="type" name="type[]" value="-4" autocomplete="off">中止
							</label>
							<span class="error-item">必填项</span>
						</td>
					</tr>
					<tr>
						<td class="text-right"><strong><span class="asterisk">*</span>原因</strong></td>
						<td>
							<textarea name="remark" class="form-control w300 reason left" autocomplete="off"></textarea>
							<span class="error-item left">必填项</span>
						</td>
					</tr>
				</table>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-affirm">确认</button>
				<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
			</div>
		</div>
	</div>
</div>
<include file="Include:javascript" />
<script type="text/javascript">
$(function(){
	//搜索
	$(".found_btn").keywordSearch("__APP__/Project/business_follow/keyword/$keyword/center_id/{$center_id}/status_id/{$status_id}/project_num/{$project_num}/project_name/{$project_name}/manager_uid/{$manager_uid}/director_uid/{$director_uid}/bus_status/{$bus_status}/stage/{$stage}");

	//启用
	$(".start-using").ajaxModal({"title_text":"启用提示框","body_text":"您确定要启用该项目吗？","url":"__APP__/Project/project_status","data":{"id":"mid","status":"status"}});

	//操作
	$(".operate").on("click",function(){
		var mid = $(this).attr("mid"),
			cid = $(this).attr("cid"),
			num = parseInt($(this).attr("num"));
		if(cid=="130003"){
			if(num<90){
				$("#myModal-operate").find('.radio-inline').eq(1).hide();
			}else{
				$("#myModal-operate").find('.radio-inline').eq(1).show();
			}
		}
		$("#myModal-operate").modal().find(".btn-affirm").attr({"mid":mid});

	});
	//确认操作
	$("#myModal-operate").find(".btn-affirm").on("click",function(){
		var tag = true,
			modal = $("#myModal-operate");

		if(modal.find(".type:checked").length==0){
			$(".type").parent("label").nextAll(".error-item").show();
			tag = false;
		}
		modal.find(".reason").each(function(){
			var val = $(this).val();
			if(val=="" || /^\s+$/.test(val)){
				$(this).next(".error-item").show();
				tag = false;
			}
		});
		modal.find(".stop_date").each(function(){
			if($(this).val()==""){
				$(this).next(".error-item").show();
				tag = false;
			}
		});

		if(tag){
			var mid = $(this).attr("mid"),
				remark = modal.find(".reason").val(),
				status = modal.find(".type:checked").val(),
				stop_date = modal.find(".stop_date").val();
			modal.hide();
			$.ajax({
				type:"POST",
				asnyc:false,
				dataType:"json",
				data:{"id":mid,"status":status,"remark":remark,"stop_date":stop_date},
				url:"__APP__/Project/project_status",
				success:function(data){
					success_pop(data['status'],data['msg']);
				}
			});
		}
	});

	//取消错误提示
	$("#myModal-operate").find(".type").on("click",function(){
		$(this).parent("label").nextAll(".error-item").hide();
	});
	$("#myModal-operate").find(".reason,.stop_date").on("focus",function(){
		$(this).next(".error-item").hide();
	});

	//取消操作
	$("#myModal-operate").on('hidden.bs.modal',function(){
		$(this).find(".error-item").hide();
		$(this).find(":radio").prop("checked",false);
		$(this).find(".reason,.stop_date").val("");
	});
	
	$(document).on("change","[name='project_num']",function(){
		var val = $(this).val();
		window.location.href="__APP__/Project/business_follow/keyword/{$keyword}/center_id/{$center_id}/status_id/{$status_id}/project_num/"+val+"/project_name/{$project_name}/manager_uid/{$manager_uid}/director_uid/{$director_uid}/bus_status/{$bus_status}/stage/{$stage}";
	});
	
	$(document).on("change","[name='project_name']",function(){
		var val = $(this).val();
		window.location.href="__APP__/Project/business_follow/keyword/{$keyword}/center_id/{$center_id}/status_id/{$status_id}/project_num/{$project_num}/project_name/"+val+"/manager_uid/{$manager_uid}/director_uid/{$director_uid}/bus_status/{$bus_status}/stage/{$stage}";
	});
	
	$(document).on("change","[name='manager_uid']",function(){
		var val = $(this).val();
		window.location.href="__APP__/Project/business_follow/keyword/{$keyword}/center_id/{$center_id}/status_id/{$status_id}/project_num/{$project_num}/project_name/{$project_name}/manager_uid/"+val+"/director_uid/{$director_uid}/bus_status/{$bus_status}/stage/{$stage}";
	});
	
	$(document).on("change","[name='director_uid']",function(){
		var val = $(this).val();
		window.location.href="__APP__/Project/business_follow/keyword/{$keyword}/center_id/{$center_id}/status_id/{$status_id}/project_num/{$project_num}/project_name/{$project_name}/manager_uid/{$manager_uid}/director_uid/"+val+"/bus_status/{$bus_status}/stage/{$stage}";
	});
	
	$(document).on("change","[name='bus_status']",function(){
		var val = $(this).val();
		window.location.href="__APP__/Project/business_follow/keyword/{$keyword}/center_id/{$center_id}/status_id/{$status_id}/project_num/{$project_num}/project_name/{$project_name}/manager_uid/{$manager_uid}/director_uid/{$director_uid}/bus_status/"+val+"/stage/{$stage}";
	});
});
</script>
</body>
</html>